home *** CD-ROM | disk | FTP | other *** search
MacBinary | 1992-09-27 | 4.8 KB | [TEXT/MPS ] |
open in:
MacOS 8.1
|
Win98
|
DOS
browse contents |
view JSON data
|
view as text
This file was processed as: MacBinary
(archive/macBinary).
Confidence | Program | Detection | Match Type | Support
|
---|
10%
| dexvert
| MacBinary (archive/macBinary)
| fallback
| Supported |
1%
| dexvert
| Text File (text/txt)
| fallback
| Supported |
100%
| file
| MacBinary II, Sun Sep 27 17:55:25 1992, modified Sun Sep 27 17:55:25 1992, creator 'MPS ', type ASCII, 4206 bytes "bigrat.pl" , at 0x10ee 428 bytes resource
| default (weak)
| |
99%
| file
| data
| default
| |
74%
| TrID
| Macintosh plain text (MacBinary)
| default
| |
25%
| TrID
| MacBinary 2
| default (weak)
| |
100%
| siegfried
| fmt/1762 MacBinary (II)
| default
| |
100%
| lsar
| MacBinary
| default
|
|
id metadata |
---|
key | value |
---|
macFileType | [TEXT] |
macFileCreator | [MPS ] |
hex view+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 09 62 69 67 72 61 74 | 2e 70 6c 00 00 00 00 00 |..bigrat|.pl.....|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 4d 50 53 | 20 00 00 00 00 00 00 00 |.TEXTMPS| .......|
|00000050| 00 00 00 00 00 10 6e 00 | 00 01 ac a6 eb de 4d a6 |......n.|......M.|
|00000060| eb de 4d 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |..M.....|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 c6 e2 00 00 |........|........|
|00000080| 70 61 63 6b 61 67 65 20 | 62 69 67 72 61 74 3b 0d |package |bigrat;.|
|00000090| 72 65 71 75 69 72 65 20 | 22 62 69 67 69 6e 74 2e |require |"bigint.|
|000000a0| 70 6c 22 3b 0d 0d 23 20 | 41 72 62 69 74 72 61 72 |pl";..# |Arbitrar|
|000000b0| 79 20 73 69 7a 65 20 72 | 61 74 69 6f 6e 61 6c 20 |y size r|ational |
|000000c0| 6d 61 74 68 20 70 61 63 | 6b 61 67 65 0d 23 0d 23 |math pac|kage.#.#|
|000000d0| 20 62 79 20 4d 61 72 6b | 20 42 69 67 67 61 72 0d | by Mark| Biggar.|
|000000e0| 23 0d 23 20 49 6e 70 75 | 74 20 76 61 6c 75 65 73 |#.# Inpu|t values|
|000000f0| 20 74 6f 20 74 68 65 73 | 65 20 72 6f 75 74 69 6e | to thes|e routin|
|00000100| 65 73 20 63 6f 6e 73 69 | 73 74 20 6f 66 20 73 74 |es consi|st of st|
|00000110| 72 69 6e 67 73 20 6f 66 | 20 74 68 65 20 66 6f 72 |rings of| the for|
|00000120| 6d 20 0d 23 20 20 20 6d | 7c 5e 5c 73 2a 5b 2b 2d |m .# m||^\s*[+-|
|00000130| 5d 3f 5b 5c 64 5c 73 5d | 2b 28 2f 5b 5c 64 5c 73 |]?[\d\s]|+(/[\d\s|
|00000140| 5d 2b 29 3f 24 7c 2e 0d | 23 20 45 78 61 6d 70 6c |]+)?$|..|# Exampl|
|00000150| 65 73 3a 0d 23 20 20 20 | 22 2b 30 2f 31 22 20 20 |es:.# |"+0/1" |
|00000160| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|00000170| 20 20 20 20 20 20 20 20 | 63 61 6e 6f 6e 69 63 61 | |canonica|
|00000180| 6c 20 7a 65 72 6f 20 76 | 61 6c 75 65 0d 23 20 20 |l zero v|alue.# |
|00000190| 20 22 33 22 20 20 20 20 | 20 20 20 20 20 20 20 20 | "3" | |
|000001a0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 20 20 | | |
|000001b0| 20 63 61 6e 6f 6e 69 63 | 61 6c 20 76 61 6c 75 65 | canonic|al value|
|000001c0| 20 22 2b 33 2f 31 22 0d | 23 20 20 20 22 20 20 20 | "+3/1".|# " |
|000001d0| 2d 31 32 33 2f 31 32 33 | 20 31 32 33 22 20 20 20 |-123/123| 123" |
|000001e0| 20 20 20 20 20 20 20 20 | 20 20 20 20 63 61 6e 6f | | cano|
|000001f0| 6e 69 63 61 6c 20 76 61 | 6c 75 65 20 22 2d 31 2f |nical va|lue "-1/|
|00000200| 31 30 30 31 22 0d 23 20 | 20 20 22 31 32 33 20 34 |1001".# | "123 4|
|00000210| 35 36 2f 37 38 39 30 22 | 20 20 20 20 20 20 20 20 |56/7890"| |
|00000220| 20 20 20 20 20 20 20 20 | 20 20 63 61 6e 6f 6e 69 | | canoni|
|00000230| 63 61 6c 20 76 61 6c 75 | 65 20 22 2b 32 30 35 37 |cal valu|e "+2057|
|00000240| 36 2f 31 33 31 35 22 0d | 23 20 4f 75 74 70 75 74 |6/1315".|# Output|
|00000250| 20 76 61 6c 75 65 73 20 | 61 6c 77 61 79 73 20 69 | values |always i|
|00000260| 6e 63 6c 75 64 65 20 61 | 20 73 69 67 6e 20 61 6e |nclude a| sign an|
|00000270| 64 20 6e 6f 20 6c 65 61 | 64 69 6e 67 20 7a 65 72 |d no lea|ding zer|
|00000280| 6f 73 20 6f 72 0d 23 20 | 20 20 77 68 69 74 65 20 |os or.# | white |
|00000290| 73 70 61 63 65 2e 0d 23 | 20 54 68 69 73 20 70 61 |space..#| This pa|
|000002a0| 63 6b 61 67 65 20 6d 61 | 6b 65 73 20 75 73 65 20 |ckage ma|kes use |
|000002b0| 6f 66 20 74 68 65 20 62 | 69 67 69 6e 74 20 70 61 |of the b|igint pa|
|000002c0| 63 6b 61 67 65 2e 0d 23 | 20 54 68 65 20 73 74 72 |ckage..#| The str|
|000002d0| 69 6e 67 20 27 4e 61 4e | 27 20 69 73 20 75 73 65 |ing 'NaN|' is use|
|000002e0| 64 20 74 6f 20 72 65 70 | 72 65 73 65 6e 74 20 74 |d to rep|resent t|
|000002f0| 68 65 20 72 65 73 75 6c | 74 20 77 68 65 6e 20 69 |he resul|t when i|
|00000300| 6e 70 75 74 20 61 72 67 | 75 6d 65 6e 74 73 20 0d |nput arg|uments .|
|00000310| 23 20 20 20 74 68 61 74 | 20 61 72 65 20 6e 6f 74 |# that| are not|
|00000320| 20 6e 75 6d 62 65 72 73 | 2c 20 61 73 20 77 65 6c | numbers|, as wel|
|00000330| 6c 20 61 73 20 74 68 65 | 20 72 65 73 75 6c 74 20 |l as the| result |
|00000340| 6f 66 20 64 69 76 69 64 | 69 6e 67 20 62 79 20 7a |of divid|ing by z|
|00000350| 65 72 6f 20 61 6e 64 0d | 23 20 20 20 20 20 20 20 |ero and.|# |
|00000360| 74 68 65 20 73 71 72 74 | 20 6f 66 20 61 20 6e 65 |the sqrt| of a ne|
|00000370| 67 61 74 69 76 65 20 6e | 75 6d 62 65 72 2e 0d 23 |gative n|umber..#|
|00000380| 20 45 78 74 72 65 61 6d | 6c 79 20 6e 61 69 76 65 | Extream|ly naive|
|00000390| 20 61 6c 67 6f 72 74 68 | 69 6d 73 20 61 72 65 20 | algorth|ims are |
|000003a0| 75 73 65 64 2e 0d 23 0d | 23 20 52 6f 75 74 69 6e |used..#.|# Routin|
|000003b0| 65 73 20 70 72 6f 76 69 | 64 65 64 20 61 72 65 3a |es provi|ded are:|
|000003c0| 0d 23 0d 23 20 20 20 72 | 6e 65 67 28 52 41 54 29 |.#.# r|neg(RAT)|
|000003d0| 20 72 65 74 75 72 6e 20 | 52 41 54 20 20 20 20 20 | return |RAT |
|000003e0| 20 20 20 20 20 20 20 20 | 20 20 20 6e 65 67 61 74 | | negat|
|000003f0| 69 6f 6e 0d 23 20 20 20 | 72 61 62 73 28 52 41 54 |ion.# |rabs(RAT|
|00000400| 29 20 72 65 74 75 72 6e | 20 52 41 54 20 20 20 20 |) return| RAT |
|00000410| 20 20 20 20 20 20 20 20 | 20 20 20 20 61 62 73 6f | | abso|
|00000420| 6c 75 74 65 20 76 61 6c | 75 65 0d 23 20 20 20 72 |lute val|ue.# r|
|00000430| 63 6d 70 28 52 41 54 2c | 52 41 54 29 20 72 65 74 |cmp(RAT,|RAT) ret|
|00000440| 75 72 6e 20 43 4f 44 45 | 20 20 20 20 20 20 20 20 |urn CODE| |
|00000450| 20 20 20 63 6f 6d 70 61 | 72 65 20 6e 75 6d 62 65 | compa|re numbe|
|00000460| 72 73 20 28 75 6e 64 65 | 66 2c 3c 30 2c 3d 30 2c |rs (unde|f,<0,=0,|
|00000470| 3e 30 29 0d 23 20 20 20 | 72 61 64 64 28 52 41 54 |>0).# |radd(RAT|
|00000480| 2c 52 41 54 29 20 72 65 | 74 75 72 6e 20 52 41 54 |,RAT) re|turn RAT|
|00000490| 20 20 20 20 20 20 20 20 | 20 20 20 20 61 64 64 69 | | addi|
|000004a0| 74 69 6f 6e 0d 23 20 20 | 20 72 73 75 62 28 52 41 |tion.# | rsub(RA|
|000004b0| 54 2c 52 41 54 29 20 72 | 65 74 75 72 6e 20 52 41 |T,RAT) r|eturn RA|
|000004c0| 54 20 20 20 20 20 20 20 | 20 20 20 20 20 73 75 62 |T | sub|
|000004d0| 74 72 61 63 74 69 6f 6e | 0d 23 20 20 20 72 6d 75 |traction|.# rmu|
|000004e0| 6c 28 52 41 54 2c 52 41 | 54 29 20 72 65 74 75 72 |l(RAT,RA|T) retur|
|000004f0| 6e 20 52 41 54 20 20 20 | 20 20 20 20 20 20 20 20 |n RAT | |
|00000500| 20 6d 75 6c 74 69 70 6c | 69 63 61 74 69 6f 6e 0d | multipl|ication.|
|00000510| 23 20 20 20 72 64 69 76 | 28 52 41 54 2c 52 41 54 |# rdiv|(RAT,RAT|
|00000520| 29 20 72 65 74 75 72 6e | 20 52 41 54 20 20 20 20 |) return| RAT |
|00000530| 20 20 20 20 20 20 20 20 | 64 69 76 69 73 69 6f 6e | |division|
|00000540| 0d 23 20 20 20 72 6d 6f | 64 28 52 41 54 29 20 72 |.# rmo|d(RAT) r|
|00000550| 65 74 75 72 6e 20 28 52 | 41 54 2c 52 41 54 29 20 |eturn (R|AT,RAT) |
|00000560| 20 20 20 20 20 20 20 20 | 20 69 6e 74 65 67 65 72 | | integer|
|00000570| 20 61 6e 64 20 66 72 61 | 63 74 69 6f 6e 61 6c 20 | and fra|ctional |
|00000580| 70 61 72 74 73 0d 23 20 | 20 20 72 6e 6f 72 6d 28 |parts.# | rnorm(|
|00000590| 52 41 54 29 20 72 65 74 | 75 72 6e 20 52 41 54 20 |RAT) ret|urn RAT |
|000005a0| 20 20 20 20 20 20 20 20 | 20 20 20 20 20 20 6e 6f | | no|
|000005b0| 72 6d 61 6c 69 7a 61 74 | 69 6f 6e 0d 23 20 20 20 |rmalizat|ion.# |
|000005c0| 72 73 71 72 74 28 52 41 | 54 2c 20 63 79 63 6c 65 |rsqrt(RA|T, cycle|
|000005d0| 73 29 20 72 65 74 75 72 | 6e 20 52 41 54 20 20 20 |s) retur|n RAT |
|000005e0| 20 20 20 20 73 71 75 61 | 72 65 20 72 6f 6f 74 0d | squa|re root.|
|000005f0| 0c 0d 23 20 43 6f 6e 76 | 65 72 74 20 61 20 6e 75 |..# Conv|ert a nu|
|00000600| 6d 62 65 72 20 74 6f 20 | 74 68 65 20 63 61 6e 6f |mber to |the cano|
|00000610| 6e 69 63 61 6c 20 73 74 | 72 69 6e 67 20 66 6f 72 |nical st|ring for|
|00000620| 6d 20 6d 7c 5e 5b 2b 2d | 5d 5c 64 2b 2f 5c 64 2b |m m|^[+-|]\d+/\d+|
|00000630| 7c 2e 0d 73 75 62 20 6d | 61 69 6e 27 72 6e 6f 72 ||..sub m|ain'rnor|
|00000640| 6d 20 7b 20 23 28 73 74 | 72 69 6e 67 29 20 72 65 |m { #(st|ring) re|
|00000650| 74 75 72 6e 20 72 61 74 | 5f 6e 75 6d 0d 20 20 20 |turn rat|_num. |
|00000660| 20 6c 6f 63 61 6c 28 24 | 5f 29 20 3d 20 40 5f 3b | local($|_) = @_;|
|00000670| 0d 20 20 20 20 73 2f 5c | 73 2b 2f 2f 67 3b 0d 20 |. s/\|s+//g;. |
|00000680| 20 20 20 69 66 20 28 6d | 23 5e 28 5b 2b 2d 5d 3f | if (m|#^([+-]?|
|00000690| 5c 64 2b 29 28 2f 28 5c | 64 2a 5b 31 2d 39 5d 30 |\d+)(/(\|d*[1-9]0|
|000006a0| 2a 29 29 3f 24 23 29 20 | 7b 0d 09 26 6e 6f 72 6d |*))?$#) |{..&norm|
|000006b0| 28 24 31 2c 20 24 33 20 | 3f 20 24 33 20 3a 20 27 |($1, $3 |? $3 : '|
|000006c0| 2b 31 27 29 3b 0d 20 20 | 20 20 7d 20 65 6c 73 65 |+1');. | } else|
|000006d0| 20 7b 0d 09 27 4e 61 4e | 27 3b 0d 20 20 20 20 7d | {..'NaN|';. }|
|000006e0| 0d 7d 0d 0d 23 20 4e 6f | 72 6d 61 6c 69 7a 65 20 |.}..# No|rmalize |
|000006f0| 62 79 20 72 65 64 75 63 | 69 6e 67 20 74 6f 20 6c |by reduc|ing to l|
|00000700| 6f 77 65 73 74 20 74 65 | 72 6d 73 0d 73 75 62 20 |owest te|rms.sub |
|00000710| 6e 6f 72 6d 20 7b 20 23 | 28 62 69 6e 74 2c 20 62 |norm { #|(bint, b|
|00000720| 69 6e 74 29 20 72 65 74 | 75 72 6e 20 72 61 74 5f |int) ret|urn rat_|
|00000730| 6e 75 6d 0d 20 20 20 20 | 6c 6f 63 61 6c 28 24 6e |num. |local($n|
|00000740| 75 6d 2c 24 64 6f 6d 29 | 20 3d 20 40 5f 3b 0d 20 |um,$dom)| = @_;. |
|00000750| 20 20 20 69 66 20 28 24 | 6e 75 6d 20 65 71 20 27 | if ($|num eq '|
|00000760| 4e 61 4e 27 29 20 7b 0d | 09 27 4e 61 4e 27 3b 0d |NaN') {.|.'NaN';.|
|00000770| 20 20 20 20 7d 20 65 6c | 73 69 66 20 28 24 64 6f | } el|sif ($do|
|00000780| 6d 20 65 71 20 27 4e 61 | 4e 27 29 20 7b 0d 09 27 |m eq 'Na|N') {..'|
|00000790| 4e 61 4e 27 3b 0d 20 20 | 20 20 7d 20 65 6c 73 69 |NaN';. | } elsi|
|000007a0| 66 20 28 24 64 6f 6d 20 | 3d 7e 20 2f 5e 5b 2b 2d |f ($dom |=~ /^[+-|
|000007b0| 5d 3f 30 2b 24 2f 29 20 | 7b 0d 09 27 4e 61 4e 27 |]?0+$/) |{..'NaN'|
|000007c0| 3b 0d 20 20 20 20 7d 20 | 65 6c 73 65 20 7b 0d 09 |;. } |else {..|
|000007d0| 6c 6f 63 61 6c 28 24 67 | 63 64 29 20 3d 20 26 27 |local($g|cd) = &'|
|000007e0| 62 67 63 64 28 24 6e 75 | 6d 2c 24 64 6f 6d 29 3b |bgcd($nu|m,$dom);|
|000007f0| 0d 09 69 66 20 28 24 67 | 63 64 20 6e 65 20 27 2b |..if ($g|cd ne '+|
|00000800| 31 27 29 20 7b 20 0d 09 | 20 20 20 20 24 6e 75 6d |1') { ..| $num|
|00000810| 20 3d 20 26 27 62 64 69 | 76 28 24 6e 75 6d 2c 24 | = &'bdi|v($num,$|
|00000820| 67 63 64 29 3b 0d 09 20 | 20 20 20 24 64 6f 6d 20 |gcd);.. | $dom |
|00000830| 3d 20 26 27 62 64 69 76 | 28 24 64 6f 6d 2c 24 67 |= &'bdiv|($dom,$g|
|00000840| 63 64 29 3b 0d 09 7d 20 | 65 6c 73 65 20 7b 0d 09 |cd);..} |else {..|
|00000850| 20 20 20 20 24 6e 75 6d | 20 3d 20 26 27 62 6e 6f | $num| = &'bno|
|00000860| 72 6d 28 24 6e 75 6d 29 | 3b 0d 09 20 20 20 20 24 |rm($num)|;.. $|
|00000870| 64 6f 6d 20 3d 20 26 27 | 62 6e 6f 72 6d 28 24 64 |dom = &'|bnorm($d|
|00000880| 6f 6d 29 3b 0d 09 7d 0d | 09 73 75 62 73 74 72 28 |om);..}.|.substr(|
|00000890| 24 64 6f 6d 2c 30 2c 31 | 29 20 3d 20 27 27 3b 0d |$dom,0,1|) = '';.|
|000008a0| 09 22 24 6e 75 6d 2f 24 | 64 6f 6d 22 3b 0d 20 20 |."$num/$|dom";. |
|000008b0| 20 20 7d 0d 7d 0d 0d 23 | 20 6e 65 67 61 74 69 6f | }.}..#| negatio|
|000008c0| 6e 0d 73 75 62 20 6d 61 | 69 6e 27 72 6e 65 67 20 |n.sub ma|in'rneg |
|000008d0| 7b 20 23 28 72 61 74 5f | 6e 75 6d 29 20 72 65 74 |{ #(rat_|num) ret|
|000008e0| 75 72 6e 20 72 61 74 5f | 6e 75 6d 0d 20 20 20 20 |urn rat_|num. |
|000008f0| 6c 6f 63 61 6c 28 24 5f | 29 20 3d 20 26 27 72 6e |local($_|) = &'rn|
|00000900| 6f 72 6d 28 24 5f 5b 30 | 5d 29 3b 0d 20 20 20 20 |orm($_[0|]);. |
|00000910| 74 72 2f 2d 2b 2f 2b 2d | 2f 20 69 66 20 28 24 5f |tr/-+/+-|/ if ($_|
|00000920| 20 6e 65 20 27 2b 30 2f | 31 27 29 3b 0d 20 20 20 | ne '+0/|1');. |
|00000930| 20 24 5f 3b 0d 7d 0d 0d | 23 20 61 62 73 6f 6c 75 | $_;.}..|# absolu|
|00000940| 74 65 20 76 61 6c 75 65 | 0d 73 75 62 20 6d 61 69 |te value|.sub mai|
|00000950| 6e 27 72 61 62 73 20 7b | 20 23 28 72 61 74 5f 6e |n'rabs {| #(rat_n|
|00000960| 75 6d 29 20 72 65 74 75 | 72 6e 20 24 72 61 74 5f |um) retu|rn $rat_|
|00000970| 6e 75 6d 0d 20 20 20 20 | 6c 6f 63 61 6c 28 24 5f |num. |local($_|
|00000980| 29 20 3d 20 26 27 72 6e | 6f 72 6d 28 24 5f 5b 30 |) = &'rn|orm($_[0|
|00000990| 5d 29 3b 0d 20 20 20 20 | 73 75 62 73 74 72 28 24 |]);. |substr($|
|000009a0| 5f 2c 30 2c 31 29 20 3d | 20 27 2b 27 20 75 6e 6c |_,0,1) =| '+' unl|
|000009b0| 65 73 73 20 24 5f 20 65 | 71 20 27 4e 61 4e 27 3b |ess $_ e|q 'NaN';|
|000009c0| 0d 20 20 20 20 24 5f 3b | 0d 7d 0d 0d 23 20 6d 75 |. $_;|.}..# mu|
|000009d0| 6c 74 69 70 69 63 61 74 | 69 6f 6e 0d 73 75 62 20 |ltipicat|ion.sub |
|000009e0| 6d 61 69 6e 27 72 6d 75 | 6c 20 7b 20 23 28 72 61 |main'rmu|l { #(ra|
|000009f0| 74 5f 6e 75 6d 2c 20 72 | 61 74 5f 6e 75 6d 29 20 |t_num, r|at_num) |
|00000a00| 72 65 74 75 72 6e 20 72 | 61 74 5f 6e 75 6d 0d 20 |return r|at_num. |
|00000a10| 20 20 20 6c 6f 63 61 6c | 28 24 78 6e 2c 24 78 64 | local|($xn,$xd|
|00000a20| 29 20 3d 20 73 70 6c 69 | 74 28 27 2f 27 2c 26 27 |) = spli|t('/',&'|
|00000a30| 72 6e 6f 72 6d 28 24 5f | 5b 30 5d 29 29 3b 0d 20 |rnorm($_|[0]));. |
|00000a40| 20 20 20 6c 6f 63 61 6c | 28 24 79 6e 2c 24 79 64 | local|($yn,$yd|
|00000a50| 29 20 3d 20 73 70 6c 69 | 74 28 27 2f 27 2c 26 27 |) = spli|t('/',&'|
|00000a60| 72 6e 6f 72 6d 28 24 5f | 5b 31 5d 29 29 3b 0d 20 |rnorm($_|[1]));. |
|00000a70| 20 20 20 26 6e 6f 72 6d | 28 26 27 62 6d 75 6c 28 | &norm|(&'bmul(|
|00000a80| 24 78 6e 2c 24 79 6e 29 | 2c 26 27 62 6d 75 6c 28 |$xn,$yn)|,&'bmul(|
|00000a90| 24 78 64 2c 24 79 64 29 | 29 3b 0d 7d 0d 0d 23 20 |$xd,$yd)|);.}..# |
|00000aa0| 64 69 76 69 73 69 6f 6e | 0d 73 75 62 20 6d 61 69 |division|.sub mai|
|00000ab0| 6e 27 72 64 69 76 20 7b | 20 23 28 72 61 74 5f 6e |n'rdiv {| #(rat_n|
|00000ac0| 75 6d 2c 20 72 61 74 5f | 6e 75 6d 29 20 72 65 74 |um, rat_|num) ret|
|00000ad0| 75 72 6e 20 72 61 74 5f | 6e 75 6d 0d 20 20 20 20 |urn rat_|num. |
|00000ae0| 6c 6f 63 61 6c 28 24 78 | 6e 2c 24 78 64 29 20 3d |local($x|n,$xd) =|
|00000af0| 20 73 70 6c 69 74 28 27 | 2f 27 2c 26 27 72 6e 6f | split('|/',&'rno|
|00000b00| 72 6d 28 24 5f 5b 30 5d | 29 29 3b 0d 20 20 20 20 |rm($_[0]|));. |
|00000b10| 6c 6f 63 61 6c 28 24 79 | 6e 2c 24 79 64 29 20 3d |local($y|n,$yd) =|
|00000b20| 20 73 70 6c 69 74 28 27 | 2f 27 2c 26 27 72 6e 6f | split('|/',&'rno|
|00000b30| 72 6d 28 24 5f 5b 31 5d | 29 29 3b 0d 20 20 20 20 |rm($_[1]|));. |
|00000b40| 26 6e 6f 72 6d 28 26 27 | 62 6d 75 6c 28 24 78 6e |&norm(&'|bmul($xn|
|00000b50| 2c 24 79 64 29 2c 26 27 | 62 6d 75 6c 28 24 78 64 |,$yd),&'|bmul($xd|
|00000b60| 2c 24 79 6e 29 29 3b 0d | 7d 0d 0c 0d 23 20 61 64 |,$yn));.|}...# ad|
|00000b70| 64 69 74 69 6f 6e 0d 73 | 75 62 20 6d 61 69 6e 27 |dition.s|ub main'|
|00000b80| 72 61 64 64 20 7b 20 23 | 28 72 61 74 5f 6e 75 6d |radd { #|(rat_num|
|00000b90| 2c 20 72 61 74 5f 6e 75 | 6d 29 20 72 65 74 75 72 |, rat_nu|m) retur|
|00000ba0| 6e 20 72 61 74 5f 6e 75 | 6d 0d 20 20 20 20 6c 6f |n rat_nu|m. lo|
|00000bb0| 63 61 6c 28 24 78 6e 2c | 24 78 64 29 20 3d 20 73 |cal($xn,|$xd) = s|
|00000bc0| 70 6c 69 74 28 27 2f 27 | 2c 26 27 72 6e 6f 72 6d |plit('/'|,&'rnorm|
|00000bd0| 28 24 5f 5b 30 5d 29 29 | 3b 0d 20 20 20 20 6c 6f |($_[0]))|;. lo|
|00000be0| 63 61 6c 28 24 79 6e 2c | 24 79 64 29 20 3d 20 73 |cal($yn,|$yd) = s|
|00000bf0| 70 6c 69 74 28 27 2f 27 | 2c 26 27 72 6e 6f 72 6d |plit('/'|,&'rnorm|
|00000c00| 28 24 5f 5b 31 5d 29 29 | 3b 0d 20 20 20 20 26 6e |($_[1]))|;. &n|
|00000c10| 6f 72 6d 28 26 27 62 61 | 64 64 28 26 27 62 6d 75 |orm(&'ba|dd(&'bmu|
|00000c20| 6c 28 24 78 6e 2c 24 79 | 64 29 2c 26 27 62 6d 75 |l($xn,$y|d),&'bmu|
|00000c30| 6c 28 24 79 6e 2c 24 78 | 64 29 29 2c 26 27 62 6d |l($yn,$x|d)),&'bm|
|00000c40| 75 6c 28 24 78 64 2c 24 | 79 64 29 29 3b 0d 7d 0d |ul($xd,$|yd));.}.|
|00000c50| 0d 23 20 73 75 62 74 72 | 61 63 74 69 6f 6e 0d 73 |.# subtr|action.s|
|00000c60| 75 62 20 6d 61 69 6e 27 | 72 73 75 62 20 7b 20 23 |ub main'|rsub { #|
|00000c70| 28 72 61 74 5f 6e 75 6d | 2c 20 72 61 74 5f 6e 75 |(rat_num|, rat_nu|
|00000c80| 6d 29 20 72 65 74 75 72 | 6e 20 72 61 74 5f 6e 75 |m) retur|n rat_nu|
|00000c90| 6d 0d 20 20 20 20 6c 6f | 63 61 6c 28 24 78 6e 2c |m. lo|cal($xn,|
|00000ca0| 24 78 64 29 20 3d 20 73 | 70 6c 69 74 28 27 2f 27 |$xd) = s|plit('/'|
|00000cb0| 2c 26 27 72 6e 6f 72 6d | 28 24 5f 5b 30 5d 29 29 |,&'rnorm|($_[0]))|
|00000cc0| 3b 0d 20 20 20 20 6c 6f | 63 61 6c 28 24 79 6e 2c |;. lo|cal($yn,|
|00000cd0| 24 79 64 29 20 3d 20 73 | 70 6c 69 74 28 27 2f 27 |$yd) = s|plit('/'|
|00000ce0| 2c 26 27 72 6e 6f 72 6d | 28 24 5f 5b 31 5d 29 29 |,&'rnorm|($_[1]))|
|00000cf0| 3b 0d 20 20 20 20 26 6e | 6f 72 6d 28 26 27 62 73 |;. &n|orm(&'bs|
|00000d00| 75 62 28 26 27 62 6d 75 | 6c 28 24 78 6e 2c 24 79 |ub(&'bmu|l($xn,$y|
|00000d10| 64 29 2c 26 27 62 6d 75 | 6c 28 24 79 6e 2c 24 78 |d),&'bmu|l($yn,$x|
|00000d20| 64 29 29 2c 26 27 62 6d | 75 6c 28 24 78 64 2c 24 |d)),&'bm|ul($xd,$|
|00000d30| 79 64 29 29 3b 0d 7d 0d | 0d 23 20 63 6f 6d 70 61 |yd));.}.|.# compa|
|00000d40| 72 69 73 6f 6e 0d 73 75 | 62 20 6d 61 69 6e 27 72 |rison.su|b main'r|
|00000d50| 63 6d 70 20 7b 20 23 28 | 72 61 74 5f 6e 75 6d 2c |cmp { #(|rat_num,|
|00000d60| 20 72 61 74 5f 6e 75 6d | 29 20 72 65 74 75 72 6e | rat_num|) return|
|00000d70| 20 63 6f 6e 64 5f 63 6f | 64 65 0d 20 20 20 20 6c | cond_co|de. l|
|00000d80| 6f 63 61 6c 28 24 78 6e | 2c 24 78 64 29 20 3d 20 |ocal($xn|,$xd) = |
|00000d90| 73 70 6c 69 74 28 27 2f | 27 2c 26 27 72 6e 6f 72 |split('/|',&'rnor|
|00000da0| 6d 28 24 5f 5b 30 5d 29 | 29 3b 0d 20 20 20 20 6c |m($_[0])|);. l|
|00000db0| 6f 63 61 6c 28 24 79 6e | 2c 24 79 64 29 20 3d 20 |ocal($yn|,$yd) = |
|00000dc0| 73 70 6c 69 74 28 27 2f | 27 2c 26 27 72 6e 6f 72 |split('/|',&'rnor|
|00000dd0| 6d 28 24 5f 5b 31 5d 29 | 29 3b 0d 20 20 20 20 26 |m($_[1])|);. &|
|00000de0| 62 69 67 69 6e 74 27 63 | 6d 70 28 26 27 62 6d 75 |bigint'c|mp(&'bmu|
|00000df0| 6c 28 24 78 6e 2c 24 79 | 64 29 2c 26 27 62 6d 75 |l($xn,$y|d),&'bmu|
|00000e00| 6c 28 24 79 6e 2c 24 78 | 64 29 29 3b 0d 7d 0d 0d |l($yn,$x|d));.}..|
|00000e10| 23 20 69 6e 74 20 61 6e | 64 20 66 72 61 63 20 70 |# int an|d frac p|
|00000e20| 61 72 74 73 0d 73 75 62 | 20 6d 61 69 6e 27 72 6d |arts.sub| main'rm|
|00000e30| 6f 64 20 7b 20 23 28 72 | 61 74 5f 6e 75 6d 29 20 |od { #(r|at_num) |
|00000e40| 72 65 74 75 72 6e 20 28 | 72 61 74 5f 6e 75 6d 2c |return (|rat_num,|
|00000e50| 72 61 74 5f 6e 75 6d 29 | 0d 20 20 20 20 6c 6f 63 |rat_num)|. loc|
|00000e60| 61 6c 28 24 78 6e 2c 24 | 78 64 29 20 3d 20 73 70 |al($xn,$|xd) = sp|
|00000e70| 6c 69 74 28 27 2f 27 2c | 26 27 72 6e 6f 72 6d 28 |lit('/',|&'rnorm(|
|00000e80| 24 5f 5b 30 5d 29 29 3b | 0d 20 20 20 20 6c 6f 63 |$_[0]));|. loc|
|00000e90| 61 6c 28 24 69 2c 24 66 | 29 20 3d 20 26 27 62 64 |al($i,$f|) = &'bd|
|00000ea0| 69 76 28 24 78 6e 2c 24 | 78 64 29 3b 0d 20 20 20 |iv($xn,$|xd);. |
|00000eb0| 20 69 66 20 28 77 61 6e | 74 61 72 72 61 79 29 20 | if (wan|tarray) |
|00000ec0| 7b 0d 09 28 22 24 69 2f | 31 22 2c 20 22 24 66 2f |{..("$i/|1", "$f/|
|00000ed0| 24 78 64 22 29 3b 0d 20 | 20 20 20 7d 20 65 6c 73 |$xd");. | } els|
|00000ee0| 65 20 7b 0d 09 22 24 69 | 2f 31 22 3b 0d 20 20 20 |e {.."$i|/1";. |
|00000ef0| 20 7d 20 20 20 0d 7d 0d | 0d 23 20 73 71 75 61 72 | } .}.|.# squar|
|00000f00| 65 20 72 6f 6f 74 20 62 | 79 20 4e 65 77 74 6f 6e |e root b|y Newton|
|00000f10| 73 20 6d 65 74 68 6f 64 | 2e 0d 23 20 20 20 63 79 |s method|..# cy|
|00000f20| 63 6c 65 73 20 73 70 65 | 63 69 66 69 65 73 20 74 |cles spe|cifies t|
|00000f30| 68 65 20 6e 75 6d 62 65 | 72 20 6f 66 20 69 74 65 |he numbe|r of ite|
|00000f40| 72 61 74 69 6f 6e 73 20 | 64 65 66 61 75 6c 74 3a |rations |default:|
|00000f50| 20 35 0d 73 75 62 20 6d | 61 69 6e 27 72 73 71 72 | 5.sub m|ain'rsqr|
|00000f60| 74 20 7b 20 23 28 66 6e | 75 6d 5f 73 74 72 5b 2c |t { #(fn|um_str[,|
|00000f70| 20 63 79 63 6c 65 73 5d | 29 20 72 65 74 75 72 6e | cycles]|) return|
|00000f80| 20 66 6e 75 6d 5f 73 74 | 72 0d 20 20 20 20 6c 6f | fnum_st|r. lo|
|00000f90| 63 61 6c 28 24 78 2c 20 | 24 73 63 61 6c 65 29 20 |cal($x, |$scale) |
|00000fa0| 3d 20 28 26 27 72 6e 6f | 72 6d 28 24 5f 5b 30 5d |= (&'rno|rm($_[0]|
|00000fb0| 29 2c 20 24 5f 5b 31 5d | 29 3b 0d 20 20 20 20 69 |), $_[1]|);. i|
|00000fc0| 66 20 28 24 78 20 65 71 | 20 27 4e 61 4e 27 29 20 |f ($x eq| 'NaN') |
|00000fd0| 7b 0d 09 27 4e 61 4e 27 | 3b 0d 20 20 20 20 7d 20 |{..'NaN'|;. } |
|00000fe0| 65 6c 73 69 66 20 28 24 | 78 20 3d 7e 20 2f 5e 2d |elsif ($|x =~ /^-|
|00000ff0| 2f 29 20 7b 0d 09 27 4e | 61 4e 27 3b 0d 20 20 20 |/) {..'N|aN';. |
|00001000| 20 7d 20 65 6c 73 65 20 | 7b 0d 09 6c 6f 63 61 6c | } else |{..local|
|00001010| 28 24 67 73 63 61 6c 65 | 2c 20 24 67 75 65 73 73 |($gscale|, $guess|
|00001020| 29 20 3d 20 28 30 2c 20 | 27 2b 31 2f 31 27 29 3b |) = (0, |'+1/1');|
|00001030| 0d 09 24 73 63 61 6c 65 | 20 3d 20 35 20 69 66 20 |..$scale| = 5 if |
|00001040| 28 21 24 73 63 61 6c 65 | 29 3b 0d 09 77 68 69 6c |(!$scale|);..whil|
|00001050| 65 20 28 24 67 73 63 61 | 6c 65 2b 2b 20 3c 20 24 |e ($gsca|le++ < $|
|00001060| 73 63 61 6c 65 29 20 7b | 0d 09 20 20 20 20 24 67 |scale) {|.. $g|
|00001070| 75 65 73 73 20 3d 20 26 | 27 72 6d 75 6c 28 26 27 |uess = &|'rmul(&'|
|00001080| 72 61 64 64 28 24 67 75 | 65 73 73 2c 26 27 72 64 |radd($gu|ess,&'rd|
|00001090| 69 76 28 24 78 2c 24 67 | 75 65 73 73 29 29 2c 22 |iv($x,$g|uess)),"|
|000010a0| 2b 31 2f 32 22 29 3b 0d | 09 7d 0d 09 22 24 67 75 |+1/2");.|.}.."$gu|
|000010b0| 65 73 73 22 3b 20 20 20 | 20 20 20 20 20 20 20 23 |ess"; | #|
|000010c0| 20 71 75 6f 74 65 73 20 | 6e 65 63 65 73 73 61 72 | quotes |necessar|
|000010d0| 79 20 64 75 65 20 74 6f | 20 70 65 72 6c 20 62 75 |y due to| perl bu|
|000010e0| 67 0d 20 20 20 20 7d 0d | 7d 0d 0d 31 3b 0d 00 00 |g. }.|}..1;...|
|000010f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001100| 00 00 01 00 00 00 01 6e | 00 00 00 6e 00 00 00 3e |.......n|...n...>|
|00001110| 0d 40 73 74 61 63 6b 20 | 3d 20 28 30 29 3b 0d 40 |.@stack |= (0);.@|
|00001120| 41 52 47 53 20 3d 20 40 | 41 52 47 56 3b 0d 66 6f |ARGS = @|ARGV;.fo|
|00001130| 09 62 69 67 72 61 74 2e | 70 6c 02 00 00 00 54 45 |.bigrat.|pl....TE|
|00001140| 58 54 4d 50 53 20 00 00 | 00 00 00 00 00 00 00 00 |XTMPS ..|........|
|00001150| 00 00 54 45 58 54 4d 50 | 53 20 00 00 00 00 00 00 |..TEXTMP|S ......|
|00001160| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001170| 00 00 a6 ea af f9 00 00 | 10 6e 00 00 01 ac 66 69 |........|.n....fi|
|00001180| 6c 65 29 20 7b 0d 20 20 | 20 20 64 6f 20 27 3a 24 |le) {. | do ':$|
|00001190| 72 63 66 69 6c 65 27 3b | 0d 7d 0d 65 6c 73 69 66 |rcfile';|.}.elsif|
|000011a0| 20 28 2d 66 20 22 24 45 | 4e 56 7b 27 4d 50 57 27 | (-f "$E|NV{'MPW'|
|000011b0| 7d 3a 24 72 63 66 69 6c | 65 22 29 20 7b 0d 20 20 |}:$rcfil|e") {. |
|000011c0| 20 20 64 6f 20 22 24 45 | 4e 56 7b 27 4d 50 57 27 | do "$E|NV{'MPW'|
|000011d0| 7d 3a 24 72 63 66 69 6c | 65 22 3b 0d 7d 0d 65 6c |}:$rcfil|e";.}.el|
|000011e0| 73 69 66 20 28 2d 66 20 | 22 24 45 4e 56 7b 27 48 |sif (-f |"$ENV{'H|
|000011f0| 4f 4d 45 27 7d 3a 24 72 | 63 66 69 6c 65 22 29 20 |OME'}:$r|cfile") |
|00001200| 00 00 00 48 00 09 4d 6f | 6e 61 63 6f 00 65 20 72 |...H..Mo|naco.e r|
|00001210| 61 74 69 6f 6e 61 6c 20 | 6d 61 74 68 20 70 61 63 |ational |math pac|
|00001220| 6b 61 67 65 0d 23 00 06 | 00 03 00 3c 00 24 01 dd |kage.#..|...<.$..|
|00001230| 02 3d 00 3c 00 24 01 dd | 02 3d a6 eb a6 0d 00 00 |.=.<.$..|.=......|
|00001240| 00 62 00 00 00 62 00 00 | 00 00 01 00 00 00 00 1e |.b...b..|........|
|00001250| 00 3c 00 24 01 dd 02 3d | 00 3c 00 24 01 dd 02 3d |.<.$...=|.<.$...=|
|00001260| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001270| 01 00 00 00 01 6e 00 00 | 00 6e 00 00 00 3e 00 41 |.....n..|.n...>.A|
|00001280| 62 20 0f 6e 00 00 00 1c | 00 3e 00 00 4d 50 53 52 |b .n....|.>..MPSR|
|00001290| 00 01 00 0a 03 ed ff ff | 00 00 00 00 00 00 00 00 |........|........|
|000012a0| 03 f0 ff ff 00 00 00 4c | 00 47 95 00 00 00 00 00 |.......L|.G......|
|000012b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000012c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000012d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000012e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000012f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+